package com.uchengwang.ui.self.banner.holder;

import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.uchengwang.R;
import com.uchengwang.functions.image.ImageManager;
import com.uchengwang.ui.cm_ui.ucity.cityBean.BannerBean;

/**
 * Created by U城网 on 2017/6/4.
 */

public class NetworkImageTitleHolderView implements Holder<BannerBean>{
    private ImageView imageView;
    private TextView textView;

    @Override
    public View createView(Context context) {
        View view = LayoutInflater.from(context).inflate(R.layout.ucity_banner_layout, null, false);
        imageView = (ImageView) view.findViewById(R.id.banner_image);
        textView = (TextView) view.findViewById(R.id.banner_title);

        return view;
    }

    @Override
    public void UpdateUI(Context context, int position, BannerBean data) {
        if (data != null){
            if (!TextUtils.isEmpty(data.getBannerCover())){
                ImageManager.getInstance().loadImage(context, imageView, data.getBannerCover(), ImageManager.ImageType.NARMOL);
            }else if (data.getJunxunId() >0){
                //为了军训日记临时加的
                ImageManager.getInstance().loadImage(context, imageView, data.getJunxunId(), ImageManager.ImageType.NARMOL);
            }

            if (!TextUtils.isEmpty(data.getBannerTitle())){
                textView.setText(data.getBannerTitle());
            }


        }




    }
}
